/**
 * Created: 2011-7-23
 * By:		eeorange
 * About:	pku 1753 - Flip Game
 * Status:	208K 125MS 
 * Details:	dfs
 */

#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <iostream>
#include <string>
using namespace std;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
unsigned int peri[16], src;

void init(){
	memset(peri, 0, sizeof(peri));
	for(int i=0; i<16; i++){
		int x = i/4;
		int y = i%4;
		peri[i] |= 1 <<  i;
		for(int j=0; j<4; j++){
			int new_x = x+dx[j];
			int new_y = y+dy[j];
			if(new_x >= 0 && new_x < 4 && new_y >= 0 && new_y < 4)
				peri[i] |= (1 << (new_x*4) + new_y);
		}
	}
}

void read_input(){
	src = 0;
	char ch;
	for(int i=0; i<16; i++)
	{
		cin >> ch;
		src |= (ch == 'b') ? (1 << i) : 0;
	}
}

int best;
void dfs(int n, int* A, int cur)
{
	if(cur == n){
		unsigned int tmp = src;
		int tot = 0;
		for(int i=0; i<n; i++) if(A[i]){ tmp ^= peri[i]; tot++; };
		if(tmp == 0 || tmp == 0xffff)
			if(best == -1 || best > tot) best = tot; 
	}
	else{
		A[cur] = 0;
		dfs(n, A, cur+1);
		A[cur] = 1;
		dfs(n, A, cur+1);
	}
}

int main(){
	init();
	read_input();

	int A[16];
	best = -1;
	dfs(16, A, 0);
	if(best != -1)
		printf("%d\n", best);
	else 
		printf("Impossible\n");
	
	
	return 0;
}

